//引入懒加载
import { lazy, Suspense } from 'react'
//引入封装好的全局导航守卫
import PrivateRoute from './request/PrivateRoute'
//引入路由插件
import { Switch, Route, Redirect } from 'react-router-dom'
const Index = lazy(() => import('./pages/index'))
const Detail = lazy(() => import('./pages/detail'))
const Login = lazy(() => import('./pages/login'))
const Register = lazy(() => import('./pages/register'))
const Goodslist = lazy(() => import('./pages/goodslist'))
const Coupon = lazy(() => import('./pages/coupon'))
function App() {
  return (
    <div className="App">
      <Suspense fallback={<div>加载中~~~~</div>}>
        <Switch>
          <Route exact path='/' component={Login}></Route>
          <Route path='/register' component={Register}></Route>
          <PrivateRoute path='/index' component={Index}></PrivateRoute>
          <PrivateRoute path='/detail' component={Detail}></PrivateRoute>
          <PrivateRoute path='/goodslist' component={Goodslist}></PrivateRoute>
          <PrivateRoute path='/coupon' component={Coupon}></PrivateRoute>
          {/* <Redirect to='/index'></Redirect> */}
        </Switch>
      </Suspense>
    </div>
  );
}

export default App;
